Public Class Account

    Private _aid As Integer
    Public Property AID() As Integer
        Get
            Return _aid
        End Get
        Set(ByVal value As Integer)
            _aid = value
        End Set
    End Property

    Private _accountName As String
    Public Property AccountName() As String
        Get
            Return _accountname
        End Get
        Set(ByVal value As String)
            _accountname = value
        End Set
    End Property

    Private _password As String
    Public Property Password() As String
        Get
            Return _password
        End Get
        Set(ByVal value As String)
            _password = value
        End Set
    End Property

    Private _grade As Integer
    Public Property Grade() As Integer
        Get
            Return _grade
        End Get
        Set(ByVal value As Integer)
            _grade = value
        End Set
    End Property

    Private _isConfirmed As Boolean
    Public Property IsConfirmed() As Boolean
        Get
            Return _isConfirmed
        End Get
        Set(ByVal value As Boolean)
            _isConfirmed = value
        End Set
    End Property

    Private _lastServer As String
    Public Property LastServer() As String
        Get
            Return _lastServer
        End Get
        Set(ByVal value As String)
            _lastServer = value
        End Set
    End Property

    Private _lastIP As String
    Public Property LastIP() As String
        Get
            Return _lastIP
        End Get
        Set(ByVal value As String)
            _lastIP = value
        End Set
    End Property

    Private _ipForce As String
    Public Property IPForce() As String
        Get
            Return _ipForce
        End Get
        Set(ByVal value As String)
            _ipForce = value
        End Set
    End Property

    Private _regDate As DateTime
    Public Property RegDate() As DateTime
        Get
            Return _regDate
        End Get
        Set(ByVal value As DateTime)
            _regDate = value
        End Set
    End Property

    Private _expireDate As DateTime
    Public Property ExpireDate() As DateTime
        Get
            Return _expireDate
        End Get
        Set(ByVal value As DateTime)
            _expireDate = value
        End Set
    End Property

    Private _lastConnectDate As DateTime
    Public Property LastConnectDate() As DateTime
        Get
            Return _lastconnectDate
        End Get
        Set(ByVal value As DateTime)
            _lastconnectDate = value
        End Set
    End Property

    Private _blockEndDate As DateTime
    Public Property BlockEndDate() As DateTime
        Get
            Return _blockEndDate
        End Get
        Set(ByVal value As DateTime)
            _blockEndDate = value
        End Set
    End Property

    ' Returns true if account has active penalty
    Public ReadOnly Property IsPenaltyActive() As Boolean
        Get
            Return _blockEndDate <> Date.MinValue And _blockEndDate >= Now
        End Get
    End Property

    ' Returns true if account has active penalty
    Public ReadOnly Property IsExpired() As Boolean
        Get
            Return _expireDate <> Date.MinValue And _expireDate < Now
        End Get
    End Property

    Public Overrides Function Equals(ByVal obj As Object) As Boolean
        Try
            If Me Is obj Then Return True
            If Not obj.GetType Is Me.GetType Then Return False
            Dim a As Account = CType(obj, Account)

            If AccountName <> "" AndAlso a.AccountName <> "" AndAlso Not a.AccountName.Equals(AccountName) Then
                Return False
            End If
            Return (Password <> "" AndAlso a.Password <> "" AndAlso a.Password.Equals(Password))
        Catch ex As Exception
            gLog.LogError(ex)
        End Try
    End Function
End Class
